# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from markdownx.admin import MarkdownxModelAdmin
from django.contrib import admin
from blog.models import Guid, BaseInfo, VisitCount, Plugins, Images
from blog.models import Category, Tag, Article, Comment, Links, User, Source
# Register your models here.

# 后台显示定制
class VisitCountAdmin(admin.ModelAdmin):
    def name(self, obj):
        return (obj.date_count)
    name.short_description = "名字"
    # 列表页显示的字段
    list_display = ('date_count', 'page_view', 'unique_vistor', 'name')
    # 可直接点击进入修改页面
    list_display_links = ('name',)
    # 可在列表页直接修改
    list_editable = ('date_count',)
    # 右侧过滤器
    list_filter = ('date_count',)
    # 搜索功能
    search_fields = ('date_count',)
    # 编辑页显示那些字段
    # fields = ('date_count', 'unique_vistor')
    # exclude = ('page_view',)
    # 分段显示
    fieldsets = (
        (None,{'fields':('date_count',)}),
        # ('高级设置',{'fields':('page_view','unique_vistor',), 'classes':('wide', 'extrapretty')})
        ('高级设置',{'fields':('page_view','unique_vistor',), 'classes':('collapse',)})
    )

# class Categ(admin.ModelAdmin):
#     def name(self,obj):
#         return (obj.name)
#     list_name = 'name'
#     list_desc = 'desc'
#     list_index = 'index'
#     fieldsets = (
#         ({'fields':('page_view','unique_vistor',)})
#     )

admin.site.register(Guid)
admin.site.register(BaseInfo)
admin.site.register(VisitCount, VisitCountAdmin)
admin.site.register(Category)
admin.site.register(Tag)
admin.site.register(Article, MarkdownxModelAdmin)
admin.site.register(Comment, MarkdownxModelAdmin)
admin.site.register(Links)
admin.site.register(User)
admin.site.register(Source)
admin.site.register(Plugins)
admin.site.register(Images)
